package com.ztesoft.web.resourcecheck;

import com.ztesoft.core.spring.context.SpringApplicationContextHolder;
import com.ztesoft.framework.log.ZTEsoftLogManager;
import com.ztesoft.web.common.Configuration;

public class ResourceCheck extends Thread{

	private ResourceCheckJob resourceCheckJob;
	private static final ZTEsoftLogManager logger = ZTEsoftLogManager.getLogger(ResourceCheck.class);
	public void init() {
		if (!Configuration.getBoolean("IS_RUNNING_RC", false)){
			logger.info("资源监测未开启...");
			return;
		}
		this.start();
	}
	@Override
	public void run() {
		long sleep = (long)(Configuration.getDouble("RC_RATE", 1) * 1000 * 60);
		resourceCheckJob = SpringApplicationContextHolder.getBean(ResourceCheckJob.class);
		while (true) {
//			logger.info("资源监测BEGIN___________________________");
			resourceCheckJob.checkResource();
//			logger.info("资源监测END___________________________");
			try {
//				logger.info("休眠{0}ms___________________________",sleep);
				Thread.sleep(sleep);
			} catch (InterruptedException e) {
			}
		}
	}
}
